@extends('web.layouts.app')

@section('styles')
    <link rel="stylesheet" type="text/css" href="{{ asset('resources/web/css/index.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ asset('resources/web/css/ucenter.css')}}">
@endsection

@section('content')
<div class="uc-wrap swrap mt20">
    <div class="uc-side L">
        <div class="uc-nav">
            <ul>
                @include('web.user_center.menu')
            </ul>
        </div>
    </div>
    <div class="uc-main uc-mainbg R">
        <!--用户信息-->
        <div class="user-main-bar">
            <div class="user-headimg">
                @if($user->userInfo->image)
                <img src="{{asset($user->userInfo->image)}}" height="84" width="84"/>
                @endif
            </div>
            <div class="user-info">
                <p class="tips">
                    @if(date('G')<11)
                    早上好
                    @elseif(date('G')<13)
                    中午好
                    @elseif(date('G')<17)
                    下午好
                    @else
                    晚上好
                    @endif,{{ $user->userInfo->name?$user->userInfo->name:$user->username}}欢迎回来！
                </p>
                <div class="items">
                    <span class="item">用户名：{{$user->username}}</span><i>|</i>
                    <span class="item">认证：
                        <em class="{{$user->userInfo->name_verified?'on':''}}id"></em>
                        <em class="{{$user->phone_number_verified?'on':''}}tel"></em>
                        <em class="{{$user->email_verified?'on':''}}email"></em>
                    </span>
                    <i>|</i>
                    <span class="item" title="{{$user->identity}}">支付账户：{{$user->identity_id}} </span>
                </div>
            </div>
        </div>
        <!--用户资产-->
        <div class="user-capital clearfix">
            <dl class="brow-total">
                <dt>累计借款</dt>
                <dd>{{number_format($projects->where('status','finish')->sum('financed_money'),2)}}元</dd>
            </dl>
            <ul class="item-list">
                <li>借款中<span>{{$projects->where('status','rush')->where('begin_time','>=',date('Y-m-d H:i:s'))->count()}}</span>笔</li>
                <li>还款中<span>{{number_format($profit->where('status','0')->sum('money')+$profit->where('status','0')->sum('profit'),2)}}</span>元</li>
                <li>已还款<span>{{number_format($profit->where('status','1')->sum('money')+$profit->where('status','1')->sum('profit'),2)}}</span>元</li>
            </ul>
            <ul class="item-list">
                <li>可用金额<span>{{number_format($sina_balance['available_balance'],2)}}</span>元</li>
                <li>冻结金额<span>{{number_format($sina_balance['balance']-$sina_balance['available_balance'],2)}}</span>元</li>
                <li>资产总额<span>{{number_format($sina_balance['balance'],2)}}</span>元</li>
                <li>基本户总额<span>
                <a style="color:#f0893e;" href="{{ action('UserCenter\UserCenterController@transferToSavingPot',['id'=>$user->id]) }}" title="转入存钱罐" alt="转入存钱罐">{{ $user->basicMoney()  }}</a></span>元</a>
                </li>
            </ul>
            <div class="do">
                <a class="cz" href="/recharge">充值</a>
                <a href="/withdraw">提现</a>
            </div>
        </div>
        <!--融资列表-->
        <div class="user-item-list pt20" id="page">
            <h3 class="title">最近借款</h3>
            <ul class="data-list financing-list">
                <li class="th">
                    <div class="col-sqh">申请号</div>
                    <div class="col-sqrq">申请日期</div>
                    <div class="col-clrq">成立日期</div>
                    <div class="col-sqje">申请金额(元)</div>
                    <div class="col-sdje">实到金额(元)</div>
                    <div class="col-zt">状态</div>
                    <div class="col-ht">合同</div>
                    <div class="col-cz">操作</div>
                </li>
                @forelse($list as $item)
                <li>
                    <div class="col-sqh apply">
                        <a href="#">{{$item->projects_name}}</a><br/>
                        {{$item->sn}}
                    </div>
                    <div class="col-sqrq">{{$item->created_at}}</div>
                    <div class="col-clrq">{{$item->published_at??'未发布'}}</div>
                    <div class="col-sqje">{{number_format($item->finance_money,2)}}</div>
                    <div class="col-sdje">{{number_format($item->financed_money,2)}}</div>
                    <div class="col-zt">{{$item->status()->name}}</div>
                    <div class="col-ht">暂无</div>
                    <div class="col-cz"><a class="orange" href="/oneProjects/{{$item->id}}">详情</a></div>
                </li>
                @empty
                <li>
                    无记录
                </li>
                @endforelse
            </ul>
            {{$links}}
        </div>
    </div>
</div>
@endsection

@section('scripts')
    <script src="{{ asset('resources/web/js/index.js') }}"></script>
@endsection